(function (window) {
    // var temp;
    //底部提示
    toastr.options = {
        closeMethod : 'fadeOut',
        hideDuration : 200,
        closeEasing : 'swing',
        showMethod : 'slideDown',
        hideMethod : 'slideUp',
        closeMethod : 'slideUp',
        showDuration : 200,
        preventDuplicates : false,
        progressBar : false,
        escapeHtml : false,
        positionClass : 'toast-bottom-full-width',
        closeButton : false,
    }
    window.hideToast = function () {
        toastr.clear();
    }
    window.removeToast = function () {
        toastr.remove();
    }
    window.showToast = function (str, type, sec) {
        // if(temp == str) window.hideToast();
        // temp = str;
        window.hideToast();
        toastr.options.timeOut = sec * 1000 || 3000;
        switch (type) {
            case 'warn':
                toastr.warning(str);
                break;
            case 'err':
                toastr.error(str);
                break;
            case 'note':
                toastr.info(str);
                break;
            case 'ok':
                toastr.success(str);
                break;
            default:
                toastr.info(str);
        };
    }

    window.chatToast = function(str,type,sec){
        toastr.options.positionClass = 'toast-top-right';
        toastr.options.timeOut = sec * 1000 || 3000;
        switch (type) {
            case 'warn':
                toastr.warning(str);
                break;
            case 'err':
                toastr.error(str);
                break;
            case 'note':
                toastr.info(str);
                break;
            case 'ok':
                toastr.success(str);
                break;
            default:
                toastr.info(str);
        };
    };

    //电话
    window.checkTel = function(value){
        var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
        var isMob=/^((\+?86)|(\(\+86\)))?(13[012356789][0-9]{8}|15[012356789][0-9]{8}|18[012356789][0-9]{8}|14[57][0-9]{8}|1349[0-9]{7})$/;
        if(isMob.test(value)||isPhone.test(value)){
            return true;
        }else{
            showToast("电话不正确","err");
            return false;
        }
    };
    //邮箱
    window.checkEmail = function(value){
        var isEmail = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
        if(isEmail.test(value)){
            return true;
        }else{
            showToast("邮箱不正确","err");
            return false;
        }
    }

})(window);

